package util;

import java.util.HashSet;
import java.util.Random;

public class Util {
    public static Random random = new Random();
    public static HashSet set = new HashSet();
    public static void swap(int[] arr,int i,int j){
        int temp = arr[i];
        arr[i] = arr[j];
        arr[j] = temp;
    }

    public static int NonRepeatingRandInt(){
        int next;
        while (set.contains(next = random.nextInt(Integer.MAX_VALUE ) % 100));
        set.add(next);
        return next;
    }
    public static Double NonRepeatingRandDouble(double to ){
        double next;
        while (set.contains(next = to * random.nextDouble()));
        set.add(next);
        return next;
    }
    public static Long[][] generateRandomArray(int n) {
        Random random = new Random();
        Long[][] array = new Long[n][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                int l = random.nextInt(Integer.MAX_VALUE);
                array[i][j] = Long.valueOf(l);
            }
        }
        return array;
    }
}
